#ifndef PROPERTIESDIALOG_H
#define PROPERTIESDIALOG_H
#include <QSet>
#include <QDialog>
#include <QStringList>

class Pin;
class GraphicsRectItem;
class Unit;
namespace Ui {
class PropertiesDialog;
}

class PropertiesDialog : public QDialog
{
    Q_OBJECT

public:
    explicit PropertiesDialog(GraphicsRectItem *item, QWidget *parent = 0);
    ~PropertiesDialog();

    void setTableHeader();
    void initTable();
    void fillTable(const QString &mode);
    void setRowValue(const QList<Pin> &rowValueList);
    void updateButtonStatus();
    void clearOperationState();
    void chkCellValid();
    void handleChange();
    void updatePin();
    void updatePinDir(const Unit &unit);


private slots:
    void onCreateBtnclicked();
    void onDelBtnclicked();
    void onConfirmBtnclicked();
    void onCancelBtnclicked();

private:
    Ui::PropertiesDialog *ui;
    const QStringList m_tableHeadList = {"引脚序号","名称","单位","描述","方向","值"};
    enum OperationMode {None,Adding} currentMode;
    int newRow = -1;
    QSet<int> rowToDelete;
    GraphicsRectItem *m_item;

};

#endif // PROPERTIESDIALOG_H
